<?php

header ('Content-type: text/html; charset=UTF-8'); 

//header('Expires: '.gmdate('D, d M Y H:i:s \G\M\T', time() - 3600));


?>

<script src="system.js"></script>
<script src="hmac-md5.js"></script>


<script language="javascript" type="text/javascript">




function returnListviewData(jsonObj){
	
	
	if( jsonObj.status == 1){
		
		var grid_view_html="";
		

		var obj_json = JSON.parse(jsonObj.data);
		
		
		//var obj_json = JSON.parse(stringjson);

		var i;
		//alert(obj_json.length);
		var columns="";
		
		
		for (i=0; i < obj_json.length; i++){
		    //var img = new Image();
		    //img.setAttribute("src",obj[i][2] + obj[i][1]);
		    //document.body.appendChild(img);
		    //alert( obj_json[i].name_view );
		    
		    //alert("name="+obj_json[i].name );
		    
		    if( columns==''){
		    	columns = columns +"<tr>";
		    	//columns = columns +"<td>#</td>";
		    	
		    	for (var key in obj_json[i]) {
			    	
					columns = columns +"<td>"+key+"</td>";
			    	
				}
				columns = columns +"</tr>";
		    }
		    
			

		    grid_view_html = grid_view_html +"<tr>";
		    //grid_view_html = grid_view_html	+"<td>>dados</a></td>";
		    		    
			
		    for (var key in obj_json[i]) {
			    	
				grid_view_html = grid_view_html +"<td>"+obj_json[i][key]+"</td>";
			    	
			}

		    grid_view_html = grid_view_html +"</tr>";
		    
		    
		}


		document.getElementById("grid_view").innerHTML = "<table border=1>"+columns+grid_view_html+"</table>";
		
			
	}else{
		alert( jsonObj.data );
		window.location.href='view_list.php';
	}
	
	

}
	
	
	
function viewData(id) 
{
	
	
	var oObject = {} ;
					
	oObject["id"] = id;
	oObject["component"] = "etl";
	oObject["controller"] = "extraction";
	oObject["task"] = "data";
	
	
	var jsonVales	=	convertToJSON(oObject);
	
	parameters	=	encodeURIComponent(
							convertToStringJSON(jsonVales));
	
	var method='GET';
		
	httpRequest ( method,
					url_API,
					parameters,
					'returnListviewData');

}


</script>


<div id="grid_view"></div>


<script>
viewData(getURIParameter('id'));
</script>